package com.huage.courseplatform.application.controller;

import cn.dev33.satoken.annotation.SaCheckRole;
import cn.dev33.satoken.annotation.SaIgnore;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huage.courseplatform.application.model.dto.HomeworkDTO;
import com.huage.courseplatform.application.model.dto.NoticeDTO;
import com.huage.courseplatform.application.model.entity.Homework;
import com.huage.courseplatform.application.model.entity.Notice;
import com.huage.courseplatform.application.model.param.HomeworkPARAM;
import com.huage.courseplatform.application.model.param.NoticePARAM;
import com.huage.courseplatform.application.service.HomeworkService;
import com.huage.courseplatform.application.service.NoticeService;
import com.huage.courseplatform.framework.annotation.RepeatSubmit;
import com.huage.courseplatform.framework.api.BaseController;
import com.huage.courseplatform.framework.model.param.PagePARAM;
import com.huage.courseplatform.framework.utils.ResultUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Insert;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping(value = "/homework")
@Api(tags = "课后作业模块")
@Slf4j
public class HomeworkController extends BaseController<Homework, HomeworkDTO, HomeworkPARAM, HomeworkService> {

    @Resource
    HomeworkService homeworkService;


    @ApiOperation(value = "分页查询学生未完成作业")
    @PostMapping(value = "/toDoPage/{pageSize}/{pageNum}/{studentId}")
    public ResultUtils<Page<HomeworkDTO>> getToDoHomeworkByPage(@PathVariable Integer pageSize,@PathVariable Integer pageNum,@PathVariable String studentId ){
        Page<Homework> page = new Page(pageNum,pageSize);
        return ResultUtils.success(super.entityToDto(homeworkService.getToDoHomeWorkPage(studentId,page)));
    }

    @ApiOperation(value = "分页查询学生完成作业")
    @PostMapping(value = "/donePage/{pageSize}/{pageNum}/{studentId}")
    public ResultUtils<Page<HomeworkDTO>> getDoneHomeworkByPage(@PathVariable Integer pageSize,@PathVariable Integer pageNum,@PathVariable String studentId ){
        Page<Homework> page = new Page(pageNum,pageSize);
        return ResultUtils.success(super.entityToDto(homeworkService.getDonePageByStudentId(studentId,page)));
    }

}
